package org.bistu.course.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.bistu.course.bean.Grade;

@Mapper
public interface GradeMapper {
	@Select("SELECT id,sid,coursename,score,createdate,updatedate FROM grade")
	List<Grade> findAll();

	@Insert("INSERT INTO grade(id,sid,coursename,score,createdate,updatedate)VALUES(#{id}, #{sid}, #{coursename}, #{score}, now(), now())")
	void addGrade(Grade grade);

	@Update("UPDATE grade SET id=#{id}, sid=#{sid}, coursename=#{coursename}, score=#{score}, updatedate=now() WHERE id=#{id}")
	void updateGrade(Grade grade);
	
	@Delete("DELETE FROM grade WHERE id=#{id}")
	void deleteGrade(int id);
	
	@Select("SELECT id,sid,coursename,score,createdate,updatedate FROM grade WHERE id=#{id}")
	Grade findById(@Param("id")int id);
}
